package com.example02;

public class OrderService {
    public static Order addorder(User user, Item[] items) {
        double allCost = 0;
        for(Item item : items) {
            allCost = allCost + item.getCount() * item.getProduct().getPrice();
        }
        if(user.getBalance() >= allCost) {
            Order o1 = new Order(user,items,allCost);
            return o1;
        }
        else {
            return null;
        }
    }
}
